class Solution {
public:
    int minSubArrayLen(int t, vector<int>& nums) {
        int n=nums.size();
        int mysum=0;
        int len=INT_MAX;
        for(int left=0,right=0;left<n,right<n;++right)
        {
            mysum+=nums[right];
            while(mysum>=t)
            {
                len=min(len,right-left+1);
                mysum-=nums[left];
                left++;
            }
        }
        if(len==INT_MAX)
            return 0;
        return len;
    }
};
